
<%@page import="br.com.fiap.vo.CursoVO"%>
<%@page import="java.util.List"%>
<%@page import="br.com.fiap.vo.UsuarioVO"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%

    UsuarioVO usuarioVO = (UsuarioVO) request.getSession().getAttribute("usuario");
    if (usuarioVO == null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp?msg=Acesso negado!");
    }

    List<CursoVO> lista = (List<CursoVO>) request.getSession().getAttribute("listaCurso");

%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cadastro de Disciplina</title>
        <link href="./css/avaliacao.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            function goBack(){
                window.history.back()
            }
            function confirmar(){
                var disciplina = document.getElementById("disciplina").value;
                                                
                if(disciplina.trim() == ""){
                    alert("Informe Nome da Disciplina! ");
                    document.getElementById("disciplina").focus();
                    return false;
                } 
                
                var curso = document.getElementById("curso").value;
                                                
                if(curso.trim() == ""){
                    alert("Selecione um Curso! ");
                    document.getElementById("curso").focus();
                    return false;
                } 
                
                document.formDisciplina.submit();

            }
        </script>
    </head>
    <body>
        <form name="formDisciplina"  method="post" action="administrador">
            <input type="hidden" id="acao" name="acao" value="cadastroDisciplina"/>
            <table  class="tabela_input">
                <tr>
                    <td>Nome da Disciplina: </td>
                    <td><input type="text" id="disciplina"  name="disciplina" value=""/></td>
                </tr>
                <tr>
                    <td>Cursos Cadastrados </td>                    
                    <td>
                        <select id="curso" name="curso">
                            <option value="-1">Selecione um Curso...</option>
                            <% for (int i = 0; i < lista.size(); i++) {%>
                            <option value="<%=lista.get(i).getIdCurso()%>"><%=lista.get(i).getNome()%></option>
                            <%}%>
                        </select>                        

                    </td>
                </tr>
            </table>
            <table  align="center">
                <tr>
                    <td><a href="#" onclick="javaScript:goBack();">Voltar</a></td>
                    <td><a href="#" onclick="javaScript:confirmar();">Confirmar</a></td>
                </tr>            
            </table>  
        </form>
    </body>
</html>
